﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Mvc;

namespace LifeTree.Mvc.ActionResults
{
    public class JsonErrorResult : ActionResult
    {
        public string ContentType { get; set; }

        public JsonRequestBehavior JsonRequestBehavior { get; set; }

        public string Message { get; set; }

        public int Code { get; set; }

        public JsonErrorResult(int code, string message)
        {
            this.Message = message;
            this.Code = code;
        }

        public override void ExecuteResult(ControllerContext context)
        {
            JsonResult result = new JsonResult()
            {
                ContentType = this.ContentType,
                JsonRequestBehavior = this.JsonRequestBehavior
            };
            result.Data = new { error = new { code = Code, msg = Message } };
            result.ExecuteResult(context);
        }
    }
}
